const Koa = require('koa')

const wechat = require('./wechat-lib/middleware')
const config = require("./config/config")
const {reply} = require("./wechat/reply")

const {initSchemas, connect} = require("./app/database/init")

;(async ()=>{

    await connect(config.db)
    initSchemas()

    // 测试token存储
    // const {test} = require("./wechat/index")
    // await test()
    // 生成服务器实例
    const app = new Koa()

    // 加载认证的中间件
    app.use(wechat(config.wechat, reply))

    app.listen(3006, ()=>{
        console.log('listen port 3006')
    })
})()

